<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>jQuery 发送 AJAX 请求</title>
    <link href="../bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="../bootstrap-3.3.7-dist/js/jquery.min.js"></script>
    <script src="../bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
</head>
<body>
    <div class="container">
        <h2 class="page-header">jQuery发送AJAX请求 </h2>
        <button class="btn btn-primary" id="btn1">GET</button>
        <button class="btn btn-danger" id="btn2">POST</button>
        <button class="btn btn-info" id="btn3">通用型方法ajax</button>
    </div>

    <script>
        $(function () {
            $('#btn1').click(function () {
                $.get('http://localhost:8000/server',{name:'小周',status:'帅'},function(data) {
                    console.log(data)
                },'json')
            })
            $('#btn2').click(function () {
                $.post('http://localhost:8000/server',{name:'小周',status: '帅'},function(data) {
                    console.log(data)
                },'json')
            })
            $('#btn3').click(function () {
                $.ajax({
                    url: 'http://localhost:8000/server'
                    ,data: {name:'小周',status:'帅'}
                    ,type: 'GET'
                    ,dataType: 'json'
                    ,success: function (data) {
                        console.log(data)
                    }
                    ,timeout: 2000
                    ,error: function () {
                    }
                })
            })
        })
    </script>



</body>
</html>